function C = G2( C, CON )
  %**********************************************************************
  %*** * Module G2
  %**********************************************************************
  %*** * Atmosphere and gravity module in SI units
  %*** * Reserved C(3510) locations are 200-299
  %*** * This module performs the following functions:
  %*** * 1) Calculates the atmospheric properties
  %*** * 2) Calculates the gravitational acceleration
  %*** * 3) Calculates the vehicle Mach number and dynamic pressure
  %*** * 4) Inputs special weather deck from INPUT.ASC
  %*** *
  %*** * MAIR=0 International Standard Atmosphere ISO 1962
  %*** *     =1 Weather Deck (Atmophere only, wind not used in 3 DoF sims)
  %*** * COMMOM /WINDS/ read in from INPUT.ASC WEATHER deck
  %*** *  (OPTMET=1 required, SI units)
  %*** *  WALT= Altitude - m
  %*** *  WDIR= Wind Direction (from North) - deg
  %*** *  WVEL= Wind Velocity - m/s
  %*** *  RHX= Air density - kg/m^3
  %*** *  CTMP= Temperature - deg Celsius
  %*** *  WPRES= Atmospheric pressure - Pa
  %*** *  KOUNTW= Number of altitude records
  %*** *  RHW= Last altitude record
  %*** *
  %*** * MODIFICATION HISTORY
  %*** * 931007 Created by Peter Zipfel
  %*** *
  %*** ******************************************************************

  %persistent emass g r ; 
  balt=[];rho=[];ctemp=[];patm=[];

  global winds_1; if isempty(winds_1), winds_1=zeros(1,50); end;
  global winds_2; if isempty(winds_2), winds_2=zeros(1,50); end;
  global winds_3; if isempty(winds_3), winds_3=zeros(1,50); end;
  global winds_4; if isempty(winds_4), winds_4=zeros(1,50); end;
  global winds_5; if isempty(winds_5), winds_5=zeros(1,50); end;
  global winds_6; if isempty(winds_6), winds_6=zeros(1,50); end;
  global winds_7; if isempty(winds_7), winds_7=0; end;
  global winds_8; if isempty(winds_8), winds_8=0; end;
  %% common /winds/walt(50),wdir(50),wvel(50),rhx(50),ctmp(50),wpres(50),kountw,rhw;
  %% common /winds/winds_1(50),winds_2(50),winds_3(50),winds_4(50),winds_5(50),winds_6(50),winds_7,winds_8;

  %*** INPUT DATA
  mair = C(CON.MAIR);

  % MAIR = D =0:Std Atmosphere, =1: Weather Deck

  %*** INPUT FROM EXECUTIVE ROUTINE
  rearth = C(CON.REARTH);

  % REARTH = E Radius of Earth - m

  %*** INPUT FROM OTHER MODULES
  balt = C(CON.BALT);
  dvbe = C(CON.DVBE);

  % BALT= I/O Vehicle altitude = m
  % DVBE= I/G Geographic speed - m/s

  %*** DIAGNOSTICS

  tempk = C(CON.TEMPK);
  vsound = C(CON.VSOUND);

  % TEMPK = G Atmospheric temperature - degK
  % VSOUND = G Sonic speed - m/sec

  %*** ALTITUDE ABOVE CENTER OF EARTH

  rad = rearth + balt;

  %*** CALCULATE THE GRAVITY ACCELERATION

  grav=CON.G.*CON.EMASS./rad.^2;

  %*** CALCUL THE ATMOSPH DENSITY, SONIC SPEED AND ROCKET MACH NUMBER

  if(mair == 0)
    if(balt < 11000.)
      tempk=288.15-0.0065.*balt;
      patm=101325..*(tempk./288.15).^5.2559;
    else;
      tempk=216.;
      patm=22630..*exp(-0.00015769.*(balt-11000.));
    end;

    rho=patm./(CON.R.*tempk);

  else;
    [balt,winds_1,winds_4,winds_7,rho]=table(balt,winds_1,winds_4,winds_7,rho);
    [balt,winds_1,winds_5,winds_7,ctemp]=table(balt,winds_1,winds_5,winds_7,ctemp);
    [balt,winds_1,winds_6,winds_7,patm]=table(balt,winds_1,winds_6,winds_7,patm);
    tempk=ctemp+273.16;
  end;
  
  vsound=sqrt(1.4.*CON.R.*tempk);

  vmach=abs(dvbe./vsound);

  pdynmc=rho.*dvbe.^2./2.;

  %*** OUTPUT TO OTHER MODULES
  C(CON.PATM) = patm.;
  C(CON.RHO) = rho;
  C(CON.GRAV) = grav;
  C(CON.VMACH) = vmach;
  C(CON.PDYNMC) = pdynmc;

  % PATM = O Atmospheric pressure - Pa
  % RHO = O Atmospheric density - kg/m^3
  % GRAV = O Gravity acceleration - m/s^2
  % VMACH = O Mach number of rocket - ND
  % PDYNMC = O Dynamic pressure - Pa  

end